package TraLaLa.Cliente;
   
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import TraLaLa.Servidor.IFacade;
import TraLaLa.Servidor.ServiceFacadeAdmin;

public class ServiceLocator {
   private ServiceFacadeAdmin adminServiceFacade;
   private IFacade userServiceFacade;

    /** Creates a new instance of ServiceLocator */
    public ServiceLocator(){
     
    }
    public void setService(String[] args) {
    	
    	// Add your code to get the TARGET reference HERE
    	//hacer dos lookup en rmi usando los args siendo el 0y el uno la direccion ip y
    	//puerto, el dos el nombre de uno y el tres el nombre del otro
    	//String nameAdmin= "//" + args[0] + ":" + args[1] + "/" + args[3];
		String nameReceiver= "//" + args[0] + ":" + args[1] + "/" + args[2];
		try {
			//adminServiceFacade= (ServiceFacadeAdmin) Naming.lookup(nameAdmin);
			userServiceFacade= (IFacade) Naming.lookup(nameReceiver);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }

    public ServiceFacadeAdmin getAdminService() {
       return adminServiceFacade;
    }
    public IFacade getUserService() {
       return userServiceFacade;
    }
}
